/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tnmk.worktime.gui.tbl;

import java.awt.Component;
import javax.swing.JTable;
import org.apache.log4j.Logger;
import org.tnmk.worktime.service.action.Action;

/**
 *
 * @author tnmkhoi
 */
public class SelectCellEditorRenderer extends BaseCellEditorRenderer<SelectCellPanel, SelectCellPanel> {

  private static final Logger log = Logger.getLogger(SelectCellEditorRenderer.class);
  private final String bolExpression;

  public SelectCellEditorRenderer(String bolExpression) {
    super.editorComp = new SelectCellPanel(bolExpression);
    super.rendererComp = new SelectCellPanel(bolExpression);
    this.bolExpression = bolExpression;
  }

  @Override
  public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    super.getTableCellEditorComponent(table, value, isSelected, row, column);
    SelectCellPanel.autoChangeSelection(super.editorComp, bolExpression, value);
    return super.editorComp;
  }

  @Override
  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    super.rendererComp.setCheckboxValueContainer(value);
    super.rendererComp.renderCheckbox();
    return this.rendererComp;
  }

  public void setSelectAction(Action mouseClickAction) {
    super.editorComp.setAdditionalMouseClickAction(mouseClickAction);
  }

  
}
